home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / INPUT.INC < prev    next >
Text File  |  1989-06-02  |  3KB  |  130 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * input.inc - library for local input and display
  15.  *             used when compiling parts of ProDOOR as local
  16.  *             (command-line) utilities.
  17.  *)
  18.  
  19. var
  20.    linenum: integer;
  21.  
  22. {$IFDEF TRACEIO}
  23. var
  24.    tracefd: text;
  25. const
  26.    traceopen: boolean = false;
  27.    tracefile: string[15] = 'install.log';
  28. {$ENDIF}
  29.  
  30.  
  31. (* ------------------------------------------------------------ *)
  32. procedure disp(msg:  string);
  33. begin
  34.    write(output,msg);
  35.  
  36. {$IFDEF TRACEIO}
  37.    if not traceopen then
  38.    begin
  39.       assign(tracefd,tracefile);
  40.       rewrite(tracefd);
  41.       traceopen := true;
  42.    end;
  43.  
  44.    write(tracefd,msg);
  45. {$ENDIF}
  46.  
  47. end;
  48.  
  49.  
  50. procedure newline;
  51. begin
  52.    flush(output);
  53.    disp(^M^J);
  54.    inc(linenum);
  55. end;
  56.  
  57. procedure displn(msg:  string);
  58. begin
  59.    disp(msg);
  60.    newline;
  61. end;
  62.  
  63.  
  64. (* ------------------------------------------------------------ *)
  65. procedure input(var line:  string;
  66.                 maxlen:    integer);
  67. var
  68.    c:     char;
  69.  
  70. begin
  71.    linenum := 1;
  72.    line := '';
  73.  
  74.    repeat
  75.       flush(output);
  76.       c := readkey;
  77.  
  78.       case c of
  79.          ' '..#126:
  80.             if maxlen = 0 then
  81.             begin
  82.                line := c;
  83.                disp(c);
  84.                c := ^M;    {automatic CR}
  85.             end
  86.             else
  87.  
  88.             if length(line) < maxlen then
  89.             begin
  90.                if (wherex > 78) then
  91.                   newline;
  92.  
  93.                inc(line[0]);
  94.                line[length(line)] := c;
  95.                disp(c);
  96.             end
  97.             else
  98.                disp(^G^X^H' '^H);
  99.  
  100.          ^H,#127:
  101.             if length(line) > 0 then
  102.             begin
  103.                dec(line[0]);
  104.                disp(^H' '^H);
  105.             end;
  106.  
  107.          ^M:   ;
  108.  
  109.          ^C:   begin
  110.                    displn('^C');
  111.                    halt(99);
  112.                end;
  113.       end;
  114.  
  115.    until (c = ^M);
  116.  
  117. end;
  118.  
  119.  
  120. (* ------------------------------------------------------------ *)
  121. procedure make_log_entry(msg: string; echo: boolean);
  122. begin
  123.    displn(msg);
  124. end;
  125.  
  126. procedure flush_com;
  127. begin
  128. end;
  129.  
  130.